// @RestApi(baseUrl: 'https://5d42a6e2bc64f90014a56ca0.mockapi.io/api/v1/')
import 'package:dio/dio.dart';
import 'package:injectable/injectable.dart';
import 'package:my_desk_flutter/extions/rivepod_ext.dart';
import 'package:my_desk_flutter/model/person_info.dart';
import 'package:my_desk_flutter/model/wan_model.dart';
import 'package:my_desk_flutter/net/dio_client.dart';
import 'package:retrofit/http.dart';
import 'package:retrofit/retrofit.dart';
import 'package:my_desk_flutter/model/bus_info_model.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';
part 'wan_api.g.dart';

@riverpod
WanApi wanApi(WanApiRef ref) => WanApi(ref.read(dioClientProvider));

@RestApi(baseUrl: 'https://www.wanandroid.com')
@Singleton()
abstract class WanApi {
  @factoryMethod
  factory WanApi(Dio dio) = _WanApi;

  @POST('/user/login')
  @FormUrlEncoded()
  Future<HttpResponse> login({
    @Field() String? username,
    @Field() String? password,
  });

  @GET('/user/logout/json')
  Future<HttpResponse> logout();

  @GET('/user/lg/userinfo/json')
  Future<WanModel<PersonInfo>> personInfo(
      @CancelRequest() CancelToken cancelToken);
}
